package com.university.mentalhealthplatform.schoolV1.repository;

import com.university.mentalhealthplatform.appModels.Assessment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface AssessmentRepositoryV1 extends JpaRepository<Assessment, Integer> {


    @Query("SELECT a FROM Assessment a WHERE " +
            "(:startTime IS NULL OR a.submittedTime >= :startTime) " +
            "AND (:endTime IS NULL OR a.submittedTime <= :endTime) " +
            "AND (:evaluation IS NULL OR a.evaluation = :evaluation)")
    List<Assessment> findByFilters(@Param("startTime") LocalDateTime startTime,
                                   @Param("endTime") LocalDateTime endTime,
                                   @Param("evaluation") String evaluation);


    List<Assessment> findByEvaluation(String evaluation);

    List<Assessment> findBySubmittedTimeBetween(LocalDateTime startTime, LocalDateTime endTime);

}
